﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class AssetManager : MonoBehaviour
{
    public static AssetManager Instance;

    private void Awake()
    {
        Instance = this;
        DontDestroyOnLoad(this.gameObject);
    }

    public T LoadAssetSync<T>(string path) where T : UnityEngine.Object
    {
        return AssetDatabase.LoadAssetAtPath<T>("Assets/AssetsPackage/" + path );
    }

    public GameObject LoadAndInstantiatePrefab(string path)
    {
        GameObject gob = LoadAsset(path);
        return GameObject.Instantiate(gob);
    }
    private GameObject LoadAsset(string assetPath)
    {
        GameObject gob = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/AssetsPackage/" + assetPath + ".prefab");
        return gob;
    }

}
